<%-- 
    Document   : portfolio
    Created on : Jan 25, 2013, 12:20:59 AM
    Author     : ritu
--%>

<%@page import="java.io.InputStreamReader"%>
<%@page import="java.net.URL"%>
<%@page import="java.io.FileReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page import="java.io.File"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="connection.jsp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Company Profile</title>
<link rel="stylesheet" type="text/css" href="css/theme.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/jquery-ui-1.8.23.custom/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script>
   var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
   document.writeln('<link rel="stylesheet" type="text/css" href="css/' + StyleFile + '">');
</script>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie-sucks.css" />
<![endif]-->
</head>

<body>
	<div id="container">
    	<div id="header">
        	<h2>Stock Market Website</h2>
    <div id="topmenu">
            	<ul>
                    <li class="current"><a href="admin_home.jsp">Dashboard</a></li>
                    <li><a href="portfolio.jsp">Portfolio</a></li>
                    <li><a href="charts.jsp">Charts</a></li>
                  <!--  <li><a href="chatgroup.jsp">Chat Group</a></li>-->
                    <li><a href="experts.jsp">Experts</a></li>
                    <li><a href="emails.jsp">Emails</a></li>
              </ul>
          </div>
      </div>
      <div id="top-panel">
          <div id="panel">
          <form action="" name="quoteform" >
              	<input type="text" placeholder="Enter company symbol" name="sym_nm" id="sym_id" />
                <input type="submit" value="Get Stock Value" />
            </form>
          </div>
      </div>
        <div id="wrapper">
            <div id="content">
                <div id="box">
                    <%
                            String comnm = request.getQueryString().substring(7);
                            URL url;
                            url=new URL("http://finance.yahoo.com/d/quotes.csv?s="+comnm+"&f=nspc6k2t1ob3b2t8mwva2j1re7dy");
                            BufferedReader bf=null;
                            bf=new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
                            //File f = new File("D:/Stock_Market/web/compprof.csv");
                            //bf = new BufferedReader(new FileReader(f));
                            String s1;
                            String[] tokens=null;                   
                            if((s1=bf.readLine())!=null)
                                tokens = s1.split(",");
                            out.print("<h3>"+tokens[0].replace("\"","").trim()+"("+tokens[1].replace("\"","").trim()+")"+"</h3>");
                            float curr = Float.parseFloat(tokens[2].replace("\"","").trim()) + Float.parseFloat(tokens[3].replace("\"","").trim());
                    %>
                    <div>
                        <span style="font-size: x-large "><% out.print("<b>"+curr+"</b>");%></span>
                        <%
                        if(Float.parseFloat(tokens[2].replace("\"","").trim())<curr)
                            out.print("<span class='greencolor'><img src='img/greenarrow.ico' height='15' width='10'>"+tokens[3].replace("\"","").trim()+"</img></span>");
                        else if(Float.parseFloat(tokens[2].replace("\"","").trim())>curr)
                            out.print("<span class='redcolor'><img src='img/redarrow.ico' height='15' width='10'>"+tokens[3].replace("\"","").trim()+"</img></span>");
                        %>
                    </div>
                        <p></p>
                        <table>     
                            <thead>
                                <tr>
                                    <th><b>Current Price</b></th>
                                    <th><b>Previous Close</b></th>
                                    <th><b>Change</b></th>
                                    <th><b>Change Percent</b></th>
                                    <th><b>Last Traded Time</b></th>
                                    <th><b>Open</b></th>
                                    <th><b>Bid</b></th>
                                    <th><b>Ask</b></th>
                                    <th><b>1 yr target price</b></th>
                                </tr>
                            </thead>
                            <%
                                out.print("<tr>");
//                                out.print("<td>"+ tokens[0].replace("\"","").trim()+"</td>");
//                                out.print("<td>"+ tokens[1].replace("\"","").trim()+"</td>");
                                out.print("<td>"+ curr+"</td>");
                                out.print("<td>"+ tokens[2].replace("\"","").trim()+"</td>");
                                out.print("<td>"+ tokens[3].replace("\"","").trim()+"</td>");
                                out.print("<td>"+ tokens[4].replace("\"","").substring(5).trim()+"</td>");
                                out.print("<td>"+ tokens[5].replace("\"","").trim()+"</td>");
                                out.print("<td>"+ tokens[6].trim()+"</td>");
                                out.print("<td>"+ tokens[7].trim()+"</td>");
                                out.print("<td>"+ tokens[8].trim()+"</td>");
                                out.print("<td>"+ tokens[9].replace("\"","").trim()+"</td>");
                            %>
                        </table>
                        <br/><br/>
                        <table>
                            <thead>
                                <tr>
                                    <th><center><b>Day's Range</b></center></th>
                                    <th><center><b>52-week range</b></center></th>
                                    <th><center><b>Volume</b></center></th>
                                    <th><center><b>Average Daily Volume</b></center></th>
                                    <th><center><b>Market-cap</b></center></th>
                                    <th><center><b>p/e ratio</b></center></th>
                                    <th><center><b>EPS estimate current year</b></center></th>
                                    <th><center><b>Dividend/Share</b></center></th>
                                    <th><center><b>Dividend Yield</b></center></th>
                                    
                                </tr>
                            </thead>
                        <%
                                out.print("<tr>");
                                out.print("<td>"+ tokens[10].replace("\"","").trim()+"</td>");
                                out.print("<td>"+ tokens[11].replace("\"","").trim()+"</td>");
                                out.print("<td>"+ tokens[12].trim()+"</td>");
                                out.print("<td>"+ tokens[13].trim()+"</td>");
                                out.print("<td>"+ tokens[14].replace("\"","").trim()+"</td>");
                                out.print("<td>"+ tokens[15].trim()+"</td>");
                                out.print("<td>"+ tokens[16].trim()+"</td>");
                                out.print("<td>"+ tokens[17].trim()+"</td>");
                                out.print("<td>"+ tokens[18].trim()+"</td>");
                            %>
                        </table>
                </div>
            </div>
            <div id="sidebar">
  				<ul>
                	<li><h3><a href="#" class="house">Dashboard</a></h3>
                        <ul>
                            <li><a href="#" class="search">Search for Company </a></li>
                        </ul>
                    </li>
                   </ul>       
          </div>
      </div>
        <div id="footer">
        <div id="styleswitcher">
            <ul>
                <li><a href="javascript: document.cookie='theme='; window.location.reload();" title="Default" id="defswitch">d</a></li>
                <li><a href="javascript: document.cookie='theme=1'; window.location.reload();" title="Blue" id="blueswitch">b</a></li>
                <li><a href="javascript: document.cookie='theme=2'; window.location.reload();" title="Green" id="greenswitch">g</a></li>
                <li><a href="javascript: document.cookie='theme=3'; window.location.reload();" title="Brown" id="brownswitch">b</a></li>
                <li><a href="javascript: document.cookie='theme=4'; window.location.reload();" title="Mix" id="mixswitch">m</a></li>
            </ul>
        </div><br />

        </div>
</div>
</body>
</html>
